<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <div th:replace="admin/head :: head"></div>

    <title>作品列表</title>

    <!-- jquery.pagination -->
    <script th:src="${#request.getAttribute('ctx') + '/static/common/jquery.pagination/jquery.pagination.js'}"></script>


</head>

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a th:href="@{/admin}">首页</a>
        <a>
          <cite>作品列表</cite>
        </a>
      </span>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" th:action="@{/admin/discountcoupon/list}" method="post" id="searchForm">
            <input type="text" name="id" th:value="${discountCoupon.id}" placeholder="优惠券编号" autocomplete="off" class="layui-input">
            <input type="text" name="name" th:value="${discountCoupon.price}" placeholder="优惠券价格" autocomplete="off" class="layui-input">

            <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>
    <xblock>
        <button class="layui-btn layui-btn-danger" onclick="del('/admin/discountcoupon/delete/')"><i class="layui-icon"></i>批量删除</button>
        <button class="layui-btn" onclick="x_admin_show('添加优惠券','/admin/discountcoupon/form')"><i class="layui-icon"></i>添加</button>
        <a class="layui-btn layui-btn-small" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon">ဂ</i>
        </a>
        <span class="x-right" style="line-height:40px" th:text="|共有数据: ${page.total} 条|"></span>
    </xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <th>
                <div class="layui-unselect header layui-form-checkbox" lay-skin="primary">
                    <i class="layui-icon">&#xe605;</i>
                </div>
            </th>
            <th>编号</th>
            <th>价格</th>
            <th>所有人</th>
            <th>历史所有人</th>
            <th>创建时间</th>
            <th>状态</th>
            <th>过期时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="item:${page.list}">
            <td>
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary" th:attr="data-id=${item.id}">
                    <i class="layui-icon">&#xe605;</i>
                </div>
            </td>
            <td th:utext="${item.id}"></td>
            <td th:text="${item.price}"></td>
            <td th:text="${item.owner}"></td>
            <td th:text="${item.originalOwner}"></td>
            <td th:text="${#dates.format(item.createDate, 'yyyy-MM-dd HH:mm:ss')}"></td>
            <td cus:dict="discount-coupon-status,${item.status}"></td>
            <td th:text="${#dates.format(item.expirationDate, 'yyyy-MM-dd HH:mm:ss')}"></td>
            <td class="td-manage">
                <a title="查看" th:onclick="'x_admin_show(\'编辑\',\'/admin/discountcoupon/form?id=' + ${item.id} + '\')'"
                   href="javascript:;">
                    <i class="layui-icon">&#xe63c;</i>
                </a>
                <a title="删除" th:onclick="'del(\'/admin/discountcoupon/delete/\', ' + ${item.id} + ')'" href="javascript:;">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        </tbody>
    </table>
    <div class="page">
        <div class="page-box"></div>
    </div>

</div>
<script th:inline="javascript">
    $('.page-box').pagination({
        totalData: [[${page.total}]],
        showData: [[${page.pageSize}]],
        current: [[${page.pageNum}]],
        pageCount: [[${page.pages}]],
        coping: true,
        keepShowPN: true,
        callback: function (index) {
            $('#searchForm').attr('action', location.href.substring(0, location.href.indexOf('?') < 0 ? location.href.length : location.href.indexOf('?')) + "?pageNum=" + index.getCurrent() + "&pageSize=[[${page.pageSize}]]");
            $('#searchForm').submit();
        }
    });

    layui.use('form', function () {
        var form = layui.form;

        form.on('submit(search)', function (data) {
            this.submit();
        })

    });

</script>
</body>

</html>